@extends('backend.layouts.master')


@section('content')
    <div class="container-fluid">
            <div class="row clearfix">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="card">
                            <div class="header">
                                <h2>
                                    修改角色 # {{$role->name}}
                                </h2>
                            </div>
                            <div class="body">
                                    <form method="POST" action="{{route('admin.role.update', $role->id)}}">
                                        @csrf
                                        @method('PATCH')
                                        <div class="form-group">
                                                <div class="form-line">
                                                    <input type="text" name="name" class="form-control" value="{{$role->name}}" placeholder="角色名称">
                                                </div>
                                        </div>
                                        <label>角色权限</label>
                                            <div class="checkbox">
                                                   @forelse($permissions as $permission)
                                                        <input type="checkbox" 
                                                                @if($role->permissions->contains($permission)) checked @endif
                                                                value="{{$permission->id}}" id="md_checkbox_{{$permission->id}}" name="permission[]" class="filled-in chk-col-blue"  >
                                                        <label for="md_checkbox_{{$permission->id}}">{{$permission->name}}</label>  &nbsp;
                                                    @empty

                                                    @endforelse
                                            </div> 
                                        <hr>
                                        <button type="submit" class="btn btn-wave btn-success">提交</button>
                                        <button type="button" onclick="window.history.go(-1)" class="btn btn-wave btn-primary">返回</button>
                                    </form>
                            </div>
                        </div>
                    </div>
                </div>
    </div>
@endsection